﻿@model CustomerUserSettingsModel
@using Telerik.Web.Mvc.UI;
@using Nop.Core.Domain.Customers;
@using Nop.Core.Domain.Security;
@using (Html.BeginForm())
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-configuration.png")" alt="" />
            @T("Admin.Configuration.Settings.CustomerUser")
        </div>
        <div class="options">
            <button type="submit" name="save" value="save" class="t-button">@T("Admin.Common.Save")</button>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#@Html.FieldIdFor(model => model.CustomerSettings.AllowCustomersToUploadAvatars)").click(toggleAvatar);
            $("#@Html.FieldIdFor(model => model.CustomerSettings.UsernamesEnabled)").click(toggleUsername);
            $("#@Html.FieldIdFor(model => model.CustomerSettings.CountryEnabled)").click(toggleCountryFormField);

            toggleAvatar();
            toggleUsername();
            toggleCountryFormField();
        });

        function toggleCountryFormField() {
            if (getE('@Html.FieldIdFor(model => model.CustomerSettings.CountryEnabled)').checked) {
                $('#pnlStateProvincEnabled').show();
            }
            else {
                $('#pnlStateProvincEnabled').hide();
            }
        }

        function toggleAvatar() {
            if (getE('@Html.FieldIdFor(model => model.CustomerSettings.AllowCustomersToUploadAvatars)').checked) {
                $('#pnlDefaultAvatarEnabled').show();
            }
            else {
                $('#pnlDefaultAvatarEnabled').hide();
            }
        }

        function toggleUsername() {
            if (getE('@Html.FieldIdFor(model => model.CustomerSettings.UsernamesEnabled)').checked) {
                $('#pnlAllowUsersToChangeUsernames').show();
                $('#pnlCheckUsernameAvailability').show();
            }
            else {
                $('#pnlAllowUsersToChangeUsernames').hide();
                $('#pnlCheckUsernameAvailability').hide();
            }
        }
        
    </script>
    
    @Html.ValidationSummary(false)

    
    @Html.Telerik().TabStrip().Name("customersettings-edit").Items(x =>
{
    x.Add().Text(T("Admin.Configuration.Settings.CustomerUser.CustomerSettings").Text).Content(TabCustomerSettings().ToHtmlString()).Selected(true);
    x.Add().Text(T("Admin.Configuration.Settings.CustomerUser.DateTimeSettings").Text).Content(TabDateTimeSettings().ToHtmlString());
    x.Add().Text(T("Admin.Configuration.Settings.CustomerUser.ExternalAuthenticationSettings").Text).Content(TabExternalAuthenticationSettings().ToHtmlString());
})
}
@helper TabCustomerSettings()
    {
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.UsernamesEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.UsernamesEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.UsernamesEnabled)
            </td>
        </tr>
        <tr id="pnlAllowUsersToChangeUsernames">
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.AllowUsersToChangeUsernames):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.AllowUsersToChangeUsernames)
                @Html.ValidationMessageFor(model => model.CustomerSettings.AllowUsersToChangeUsernames)
            </td>
        </tr>
        <tr id="pnlCheckUsernameAvailability">
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.CheckUsernameAvailabilityEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.CheckUsernameAvailabilityEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.CheckUsernameAvailabilityEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.UserRegistrationType):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.CustomerSettings.UserRegistrationType, ((UserRegistrationType)Model.CustomerSettings.UserRegistrationType).ToSelectList())
                @Html.ValidationMessageFor(model => model.CustomerSettings.UserRegistrationType)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.AllowCustomersToUploadAvatars):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.AllowCustomersToUploadAvatars)
                @Html.ValidationMessageFor(model => model.CustomerSettings.AllowCustomersToUploadAvatars)
            </td>
        </tr>
        <tr id="pnlDefaultAvatarEnabled">
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.DefaultAvatarEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.DefaultAvatarEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.DefaultAvatarEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.ShowCustomersLocation):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.ShowCustomersLocation)
                @Html.ValidationMessageFor(model => model.CustomerSettings.ShowCustomersLocation)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.ShowCustomersJoinDate):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.ShowCustomersJoinDate)
                @Html.ValidationMessageFor(model => model.CustomerSettings.ShowCustomersJoinDate)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.AllowViewingProfiles):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.AllowViewingProfiles)
                @Html.ValidationMessageFor(model => model.CustomerSettings.AllowViewingProfiles)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.NotifyNewCustomerRegistration):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.NotifyNewCustomerRegistration)
                @Html.ValidationMessageFor(model => model.CustomerSettings.NotifyNewCustomerRegistration)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.HideDownloadableProductsTab):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.HideDownloadableProductsTab)
                @Html.ValidationMessageFor(model => model.CustomerSettings.HideDownloadableProductsTab)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.HideBackInStockSubscriptionsTab):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.HideBackInStockSubscriptionsTab)
                @Html.ValidationMessageFor(model => model.CustomerSettings.HideBackInStockSubscriptionsTab)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.CustomerNameFormat):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.CustomerSettings.CustomerNameFormat, ((CustomerNameFormat)Model.CustomerSettings.CustomerNameFormat).ToSelectList())
                @Html.ValidationMessageFor(model => model.CustomerSettings.CustomerNameFormat)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.HideNewsletterBlock):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.HideNewsletterBlock)
                @Html.ValidationMessageFor(model => model.CustomerSettings.HideNewsletterBlock)
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <hr />
                <b>Form fields:</b>
                <br />
                <i>You can create and manage the form fields available during registration (public store) below.</i>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.GenderEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.GenderEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.GenderEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.DateOfBirthEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.DateOfBirthEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.DateOfBirthEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.CompanyEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.CompanyEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.CompanyEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.StreetAddressEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.StreetAddressEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.StreetAddressEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.StreetAddress2Enabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.StreetAddress2Enabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.StreetAddress2Enabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.ZipPostalCodeEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.ZipPostalCodeEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.ZipPostalCodeEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.CityEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.CityEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.CityEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.CountryEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.CountryEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.CountryEnabled)
            </td>
        </tr>
        <tr id="pnlStateProvincEnabled">
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.StateProvinceEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.StateProvinceEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.StateProvinceEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.PhoneEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.PhoneEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.PhoneEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.FaxEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.FaxEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.FaxEnabled)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.NewsletterEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.NewsletterEnabled)
                @Html.ValidationMessageFor(model => model.CustomerSettings.NewsletterEnabled)
            </td>
        </tr>
    </table>
}
@helper TabDateTimeSettings()
    {
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DateTimeSettings.AllowCustomersToSetTimeZone):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.DateTimeSettings.AllowCustomersToSetTimeZone)
                @Html.ValidationMessageFor(model => model.DateTimeSettings.AllowCustomersToSetTimeZone)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DateTimeSettings.DefaultStoreTimeZoneId):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.DateTimeSettings.DefaultStoreTimeZoneId, Model.DateTimeSettings.AvailableTimeZones)
                @Html.ValidationMessageFor(model => model.DateTimeSettings.DefaultStoreTimeZoneId)
            </td>
        </tr>
    </table>
}
@helper TabExternalAuthenticationSettings()
    {
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.ExternalAuthenticationSettings.AutoRegisterEnabled):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.ExternalAuthenticationSettings.AutoRegisterEnabled)
                @Html.ValidationMessageFor(model => model.ExternalAuthenticationSettings.AutoRegisterEnabled)
            </td>
        </tr>
    </table>
}